#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#define int long long
using namespace std;

void solve()
{
	int n; cin >> n;
	vector<int> arr(n); for (auto& e : arr) cin >> e;
	sort(arr.begin(), arr.end());
	int tgt = 0;
	for (int i = 0; i < arr.size(); ++i)
	{
		if (arr[i] < tgt) continue;
		if (arr[i] == tgt) ++tgt;
		else break;
	}
	cout << tgt << endl;
}

signed main()
{
	int t; cin >> t;
	while (t--) solve();
	return 0;
}

//2 3 0 0 0 2 1 2
